#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
简单的DeepSeek API测试
"""

from openai import OpenAI

def test_api():
    """测试API调用"""
    try:
        client = OpenAI(
            api_key="sk-39f586799e5e4cfca2f59ec99aa6e687", 
            base_url="https://api.deepseek.com"
        )

        print("🔄 正在调用DeepSeek API...")
        
        response = client.chat.completions.create(
            model='deepseek-chat',
            messages=[
                {"role": "system", "content": "你是一位汽车专家"},
                {"role": "user", "content": "简单介绍比亚迪秦PLUS DM-i"},
            ],
            max_tokens=200,
            stream=False
        )

        print("✅ API调用成功！")
        print("🤖 回复：", response.choices[0].message.content)
        
    except Exception as e:
        print(f"❌ 错误：{e}")

if __name__ == "__main__":
    test_api()
